import Music from "../js/music"
import utils from "@/libs/utils"

export default {
    async mounted(el, bindings) {
        let value = await bindings.value,
            data = value[0],
            PrevOrNextclick = value[1];
        window.music = new Music({
            // 容器选择器名称
            containerSelector: el,
            PlayMode: 1, //播放模式
            defaultVolume: 0.2, //播放器声音
            playMusicUrl: data.playMusicUrl
        });
        // console.log(music);
        el.append(music.audio); // 测试用

        //上一首
        utils.addEvent(el.querySelector('.prev'), "click", function () {
            PrevOrNextclick(music.playCurIdx);
        });
        //下一首
        utils.addEvent(el.querySelector('.next'), "click", function () {
            PrevOrNextclick(music.playCurIdx);
        });
    }
}